<!--轮播图 -->
<template>
  <div class="block">
    <el-carousel height="850px" type="card" shadow="hover">
      <el-carousel-item v-for="s in swiperList" :key="s.id">
        <img class="imgdemo" :src="s.picUrl" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
// 引入Axios
import axios from "axios";

export default {
  name: "HelloWorld",
  data() {
    return {
      swiperList: [],
    };
  },
  created() {
    axios
      .get("http://localhost:3000/personalized/newsong")
      .then((response) => {
        const resList = response.data.result.map((item) => ({
          id: item.id,
          name: item.name,
          picUrl: item.picUrl,
        }));
        this.swiperList = resList;
      })
      .catch((error) => {
        console.warn("请求失败", error);
      });
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.block {
background-color: #DEE2E6;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

.imgdemo {
  width: 100%;
  height: 100%;
}
</style>
